Skip to content

chore: merging the nanobind work into main - #131

Merged
sbillinge merged 26 commits into
mainfrom
nanobind_migration_test
Nov 15, 2026
Merged

sbillinge merged 26 commits into
mainfrom
nanobind_migration_test

Conversation

@sbillinge

Copy link
Copy Markdown
Contributor

As the title suggests.

vincefn and others added 23 commits September 1, 2026 14:32
…#112,#113,#114,#115,#116)

- Update extern/objcryst submodule to origin/master (30fc8df), adding:
  GetRwHistory, minRwpVar, ReflectionProfilePseudoVoigtTCH,
  PowderPatternBackgroundHist, fixed aniso PV constructor, etc.

- nb_lsq.cpp: Add GetVarianceCovarianceMap() (dict keyed by name tuples),
  GetRwHistory() (list of Rw fractions per cycle), minRwpVar arg to
  Refine/SafeRefine, verbose overload for PrepareRefParList,
  fix SafeRefine to pass maxChi2factor in correct position

- nb_reflectionprofile.cpp: Expose concrete ReflectionProfilePseudoVoigt,
  ReflectionProfilePseudoVoigtTCH (8-arg SetProfilePar), and
  ReflectionProfilePseudoVoigtAnisotropic; add IsAnisotropic() to base

- nb_powderpatterndiffraction.cpp: Add X2XCorrPhase() method and
  SetProfile() (installs a copy of a given ReflectionProfile)

- nb_crystal.cpp: Fix pre-existing build error: replace nb::detail::keep_alive
  (non-existent in nanobind 3.x) with nb::keep_alive<1,2>() annotation

- CMakeLists.txt: Add homebrew include paths for Boost headers on macOS

- src/pyobjcryst/reflectionprofile.py: Export new concrete profile classes

- tests: Port new tests for all features from main branch and open PRs

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- pyproject: requires-python <3.16, add 3.15 classifier, version 2026.2.0rc0,
  add libboost-headers to build requirements.
- CMake: locate Boost headers from the libboost-headers Python package, else
  BOOST_INCLUDE_DIR or system/conda headers; drop hardcoded include paths.
- requirements/conda.txt: drop libboost-python and libobjcryst, add compilers.
- requirements/pip.txt: add libboost-headers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Picks up vincefn/objcryst fixes since 30fc8df:
- Invalidate March-Dollase texture cache in SetPhasePar, implement DeletePhase (vincefn/objcryst#105)
- Recalculate powder pattern when Radiation changes (vincefn/objcryst#104)
- Fix TextureEllipsoid implementation (vincefn/objcryst#103)
- Le-Bail: update extracted intensities if number of reflections changed (vincefn/objcryst#99)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…obind (#122)

* feat: port March-Dollase texture (#119) and TOF profile (#120) to nanobind

- Bind TextureMarchDollase and PowderPatternDiffraction.GetTextureMarchDollase.
  SetPhasePar is bound directly (no RefinablePar workaround) since the
  objcryst submodule (ba6ca89, vincefn/objcryst#105) now clicks the texture
  clock; DeletePhase is also exposed.
- TextureMarchDollase has RefinableObj as a second (non-zero offset) base, so
  it is registered standalone with bind_refinableobj_forwarding and added to
  extractRefinableObjArg.
- Bind ReflectionProfileDoubleExponentialPseudoVoigt; SetProfile gives a TOF
  profile copy the crystal's unit cell.
- Port tests and news items, with extra DeletePhase tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* [pre-commit.ci] auto fixes from pre-commit hooks

* ci: check out submodules and exclude vendored extern/ from pre-commit

- Pass submodules: 'true' to the scikit-package reusable workflows, so that
  extern/objcryst is available when building.
- Exclude extern/ (objcryst submodule, vendored cctbx and newmat) from
  pre-commit hooks.
- Remove duplicated test_lsq_compiled_refined_obj_erase_all_param_set (F811)
  and fix a typo flagged by codespell.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* [pre-commit.ci] auto fixes from pre-commit hooks

* [pre-commit.ci] auto fixes from pre-commit hooks

* docs: keep inline code on one line so prettier output is stable

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* revert: restore vendored extern/ sources modified by pre-commit.ci autofix

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Fix lifetime management regressions in Atom bindings

* test: add Atom/ScatteringPower lifetime tests (#123)

---------

Co-authored-by: Vincent Favre-Nicolin <vincent.favre-nicolin@esrf.fr>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The published wheels needed libObjCryst/libboost_python (Linux, macOS,
Windows) from a conda environment: the old shared wheel workflow ran
auditwheel and then removed the bundled libraries and pointed RPATH at the
conda prefix. The nanobind build links ObjCryst++, cctbx and newmat
statically and Boost is header-only, so build the wheels with cibuildwheel:

- add [tool.cibuildwheel] (cp312-cp315; manylinux x86_64, macOS native,
  Windows AMD64; tests run on every wheel)
- use the cibuildwheel shared workflow from SYMSCAE/release-scripts until
  it is released in scikit-package/release-scripts@v0
- derive the version from git tags with setuptools-scm instead of the
  static 2026.2.0rc0 placeholder
- declare packaging as a runtime dependency (used by powderpattern)
- trim unused ObjCryst++ submodule parts from the sdist
- guard the GCC-only -O0 flag and add MSVC settings in CMakeLists.txt
- ship the licenses of the statically linked code in the wheel

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nanobind has no global converter for CrystVector_REAL/CrystMatrix_REAL,
so bindings that returned them directly raised when called.

Wrap them in crystvec_to_array/crystmat_to_array:

- UnitCell.GetLatticePar(), UnitCell.GetOrthonormalCoords()
- Crystal.GetMinDistanceTable()
- ScatteringPower.GetScatteringFactor(), GetTemperatureFactor(),
  GetResonantScattFactReal(), GetResonantScattFactImag(),
  (both in the base binding and in the forwarding for ScatteringPowerAtom
  and GlobalScatteringPower)

Add tests that call each method, plus a check that no binding's
signature still returns a raw CrystVector/CrystMatrix.

fixes #127
fix: remove single-argument binding of PrepareRefParList to make it silent by default
fix: return numpy arrays from CrystVector/CrystMatrix bindings
fix: use cibuildwheel for building PyPI wheel
@sbillinge

Copy link
Copy Markdown
Contributor Author

oops, this seems to have migrated from main at some point. I am not sure when or how, but I would rather that @clemisch or @vincefn took a look because some of it is in the cpp.

Also, we seem to have two migrate-nano branches (migration-nano and this one). Please could we dig back and try and remember why we have two? Looping in @cadenmyers13 and @SYMSCAE on this too. If migration-nano is just a stale branch, let's delete it. I do know that we have been doing all our testing on this branch, so I am fairly confident that this is the good one to merge.

vincefn and others added 2 commits November 16, 2026 00:35
Main's recent commits (#107, #113, #115, #116, #119, #120) modified the
Boost.Python sources removed by the nanobind migration. Their features were
already re-implemented in nanobind, so main's file contents are discarded.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Re-implement test_anisotropic_profile_depends_on_hkl,
test_set_profile_copies_reusable_template and
test_set_profile_accepts_temporary (from #112) against the nanobind API.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@vincefn

vincefn commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

nanobind_migration_test is the correct one - I think you created the other one as a tenttative branch for migration, but nothing was done there

I'll handle the divergence with main, latest main commits had already been ported to the nanobind branch.

README also needs to be updated (no scons)

@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@c0681c0). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #131   +/-   ##
=======================================
  Coverage        ?   98.80%           
=======================================
  Files           ?       22           
  Lines           ?     2343           
  Branches        ?        0           
=======================================
  Hits            ?     2315           
  Misses          ?       28           
  Partials        ?        0           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Drop SCons and libobjcryst instructions, describe self-contained PyPI
wheels, building from source with submodules, and Debug builds via
scikit-build-core.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@vincefn

vincefn commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

README updated but probably would benefit from some more careful cleanup..

@sbillinge

Copy link
Copy Markdown
Contributor Author

Thanks @vincefn! I see a bunch of stuff on here that seems as if it is beyond nanobind, such as henke tables etc.. I am ready to merge, but please could you just confirm that this is ok on this PR?

@sbillinge
sbillinge merged commit 0970b44 into main Nov 15, 2026
7 checks passed
@sbillinge

Copy link
Copy Markdown
Contributor Author

I went ahead and merged....look for the rc release.

@vincefn

vincefn commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks @vincefn! I see a bunch of stuff on here that seems as if it is beyond nanobind, such as henke tables etc..

Thanks for merging ! Yes things like henke tables are normal - before it was libobjcryst which absorbed the dependencies including cctbx and newmat, but now they need to be embedded here. The rationale for keeping the the cctbx source rather than using the cctbx-base conda package is discussed in nanobind_migration_notes.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants